﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace cludg.Web.Core.Filters
{
	public class FilterRegistry
	{
		protected readonly IEnumerable<IFilterProvider> Providers;

		public FilterRegistry(IEnumerable<IFilterProvider> providers)
		{
			Providers = providers;
		}

		public IEnumerable<IAuthorizationFilter> GetAuthorizationFilters()
		{
			return Providers.SelectMany(provider => provider.GetAuthorizationFilters());
		}

		public IEnumerable<IActionFilter> GetActionFilters()
		{
			return Providers.SelectMany(provider => provider.GetActionFilters());			
		}

		public IEnumerable<IResultFilter> GetResultFilters()
		{
			return Providers.SelectMany(provider => provider.GetResultFilters());			
		}

		public IEnumerable<IExceptionFilter> GetExceptionFilters()
		{
			return Providers.SelectMany(provider => provider.GetExceptionFilters());
		}
	}
}
